<div th:if="*{badges !=null and !badges.isEmpty()}" th:classappend="*{badges}"></div>
<div class="image">
    <a th:href="@{*{url}}">
        <img th:if="*{media['primary']}" blc:src="@{/img/loader.gif}" th:alt="*{name}" th:title="*{name}" class="lazy"
            th:attrappend="data-original=@{*{media['primary'].url} + '?browse'}" />
        <div class="price" th:if="${#object instanceof T(org.broadleafcommerce.core.catalog.domain.ProductBundle)}">
            <div blc:fsprice="*{salePrice}" th:if="*{onSale}" th:classappend="*{defaultSku.onSale}? 'sale'"></div>
            <div blc:fsprice="*{retailPrice}" th:classappend="*{onSale}? 'has-sale'"></div>
        </div>
    </a>
</div>
<div class="content">
    <div class="title" th:text="*{name} + ' ' + *{defaultSku.Id}"></div>
    <p class="pro_desc" th:text="*{description}"></p>
</div>

<div th:class="*{'productActions productActions' + id}" th:with="checkInventory=*{defaultSku.inventoryType?.type == 'CHECK_QUANTITY'},
              availableInventory=${checkInventory ? #object.defaultSku.quantityAvailable != null and #object.defaultSku.quantityAvailable != 0 : true},
              treasureComingSoon=${checkInventory ? #object.defaultSku.quantityTotal != null and #object.defaultSku.quantityTotal == 0 : false},
              inCart=${cart.containsSku(#object.defaultSku) and #lists.isEmpty(product.productOptions)}">
    
    <div class="price" th:unless="${#object instanceof T(org.broadleafcommerce.core.catalog.domain.ProductBundle)}">
        <div blc:fsprice="*{defaultSku.salePrice.add(defaultSku.calculatedShippmentFee)}" th:if="*{defaultSku.onSale}" th:classappend="*{defaultSku.onSale}? 'sale'"></div>
        <div blc:fsprice="*{defaultSku.retailPrice.add(defaultSku.calculatedShippmentFee)}" th:classappend="*{defaultSku.onSale}? 'has-sale'"></div>
    </div>
    
    <div class="rep" th:if="${checkInventory}">
	    <div class="surplus">
	        <div class="rep_pannel"><span class="rep_mark"></span></div>
	    </div>
	    <div class="pep_num">
	        <div class="join j_surp">
	            <span>参加人次</span>
	            <span id="rep_surplus" th:unless="${treasureComingSoon}" th:text="*{defaultSku.quantityTotal - defaultSku.quantityAvailable}">150</span>
	        </div>
	        <div class="join j_all">
	            <span>总人次</span>
	            <span id="rep_total" th:text="*{defaultSku.quantityTotal}">450</span>
	        </div>
	        <div class="join j_in">
	            <span>剩余人次</span>
	            <span th:text="*{defaultSku.quantityAvailable}">300</span>
	        </div>
	    </div>
	</div>

    <div th:if="${treasureComingSoon}" class="out_of_stock loot">
        <span disabled="disabled" class="inCart" th:text="#{product.treasureComingSoon}">即将开始</span>
    </div>
    
    <div th:if="${!treasureComingSoon and !availableInventory}" class="out_of_stock loot">
        <span disabled="disabled" class="inCart" th:text="#{product.treasureOutOfStock}">抢光了</span>
    </div>

    <div class="loot" th:classappend="${treasureComingSoon or !availableInventory}? ' hidden'">
        <blc:form method="POST" th:action="@{/cart/add}" target="_blank" >
            <input type="hidden" name="productId" th:value="*{id}" />
            <input type="hidden" name="quantity" value="1" />
            <input type="hidden" name="hasProductOptions" th:value="*{!#lists.isEmpty(productOptions)}" />
            <input type="submit" class="addToCart" th:value="#{product.treasure}"/>
        </blc:form>
    </div>
</div>


<div style="display: none;" th:id="*{'productOptions' + id}" class="product-options modal">
    <h3 th:text="*{name}"></h3>
    <div class="product-options" th:substituteby="catalog/partials/productOptions" />
    <input type="button" class="addToCart" th:value="#{product.buyNow}" />
</div>
